<template>
    <div>
        <!-- -------药品生产------ -->
        <!-- 任务受理 -->
        <manufacturingTaskAcceptance
         ref="manufacturingTaskAcceptanceRef" 
         :addEditParameter="manufacturingTaskAcceptance.addEditParameter" 
         @successReturn="successReturn"  @reviseClick="reviseClick"
        />
        <!-- 材料审查 旧（目前没有在用） -->
        <manufacturingManufacturing ref="manufacturingManufacturingRef"
         @successReturn="successReturn" @reviseClick="reviseClick" />

         <!-- 技术审查，目前叫：材料审查--在用 -->
         <manufacturingTechnicalReview ref="manufacturingTechnicalReviewRef"
         @successReturn="successReturn" @reviseClick="reviseClick" />

         <!-- 退回政务 -->
         <manufacturingReturnGovernment ref="manufacturingReturnGovernmentRef"
         @successReturn="successReturn" @reviseClick="reviseClick"/>

         <!-- 补齐补正 -->
         <manufacturingCompleteAndCorrect ref="manufacturingCompleteAndCorrectRef"
         @successReturn="successReturn" @reviseClick="reviseClick"/>

         <!-- 方案制定、方案审核、方案审批 -->
        <manufacturingPlanProduction ref="manufacturingPlanProductionRef"
         @successReturn="successReturn" @reviseClick="reviseClick" />
         <!-- 技术审评 -->
        <manufacturingOnSiteInspection ref="manufacturingOnSiteInspectionRef"
         @successReturn="successReturn" @reviseClick="reviseClick" />
         <!-- 综合评定 -->
        <manufacturingComprehensive ref="manufacturingComprehensiveRef"
         @successReturn="successReturn" @reviseClick="reviseClick" />
         <!-- 科室复核、移送确认 -->
        <departmentReview ref="departmentReviewRef"
         @successReturn="successReturn" @reviseClick="reviseClick" />
    </div>
</template>
<script>
import {
    spcyGetJobConcernByJobId,
} from './service/index'
import moment from 'moment'
import manufacturingTaskAcceptance from '../allHandlingPage/manufacturing/taskAcceptance/increase'
import manufacturingManufacturing from '../allHandlingPage/manufacturing/materialReview/increase'
import manufacturingPlanProduction from '../allHandlingPage/manufacturing/planProduction/increase.vue'
import manufacturingOnSiteInspection from '../allHandlingPage/manufacturing/onSiteInspection/increase.vue'
import manufacturingComprehensive from '../allHandlingPage/manufacturing/comprehensive/increase.vue'
import manufacturingTechnicalReview from '../allHandlingPage/manufacturing/technicalReview/increase.vue'
import manufacturingReturnGovernment from '../allHandlingPage/manufacturing/returnGovernment/increase.vue'
import manufacturingCompleteAndCorrect from '../allHandlingPage/manufacturing/completeAndCorrect/increase.vue'
import departmentReview from '../allHandlingPage/manufacturing/departmentReview/increase.vue'
export default {
    components:{
        manufacturingTaskAcceptance,
        manufacturingManufacturing,
        manufacturingPlanProduction,
        manufacturingOnSiteInspection,
        manufacturingComprehensive,
        manufacturingTechnicalReview,
        manufacturingReturnGovernment,
        manufacturingCompleteAndCorrect,
        departmentReview,
    },
    props:{

    },
    data(){
        return{
            //环节详情
            linkDetails:{},
            //药品生产-任务受理
            manufacturingTaskAcceptance:{addEditParameter:{}},
            setOfData:{},
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        //刷新表格
        successReturn(){
            this.$emit('successReturn')
        },
        //重新获取当前列的数据
        reviseClick(row){
            //console.log(row)
            this.getData(row)
        },
        //获取表格当前列--以及当前列详情
        getData(row){
            //console.log(row.ref)
            spcyGetJobConcernByJobId({jobid:row.jobid}).then(res=>{
                if(res.code == 200){
                    this.$nextTick(()=>{
                        if(this[row.ref+'Click']){
                            this[row.ref+'Click'](row)
                        }else{
                            this.$message.warning('当前暂无对应办理页面')
                        }
                    })
                    //console.log(res)
                    this.linkDetails = {...row,...res.result}
                    let data = this.linkDetails
                    let sqsx = this.linkDetails.sqsx
                    this.setOfData = {
                        ...row,
                        fywflcode:'001002',
                        ...this.linkDetails,
                        jobid:data.job.id,
                        fblzt:data.job.fblzt,
                        fthyj:data.job.fthyj,
                        ...sqsx,
                        sqsxid:sqsx.id,
                        fslzt:String(sqsx.fslzt),
                        fsqsj:sqsx.fsqsj?moment(sqsx.fsqsj).format('YYYY-MM-DD'):'',
                        fslsj:sqsx.fslsj?moment(sqsx.fslsj).format('YYYY-MM-DD'):'',
                        isOwn:true,
                        dbrid:[],
                        opinion:'',//办理意见
                        smgflag:false,//是否发送短信
                        ...data.qy,
                        fqymc:sqsx.fqymc,
                    }
                }else{
                    this.$message.warning(res.message)
                }
            })
        },
        manufacturingTaskAcceptanceClick(row){//药品生产--任务受理
            this.setOfData = {
                ...this.setOfData,
                isTabs:true,
                commpStepIndex:0,
            }
            this.manufacturingTaskAcceptance['addEditParameter'] = this.setOfData
            this.$refs[row.ref+'Ref'].visibleShow = true
            this.$refs[row.ref+'Ref'].spinning = true
            this.$refs[row.ref+'Ref'].getData(this.setOfData)
        },
        manufacturingManufacturingClick(row){//药品生产--材料审查--旧（不在用）
            this.setOfData = {
                ...this.setOfData,
                isReadOnly:true,
                isOwn:false,
                
            }
            this.$refs[row.ref+'Ref'].visible = true
            this.$refs[row.ref+'Ref'].spinning = true
            this.$refs[row.ref+'Ref'].getData(this.setOfData)
        },
        manufacturingTechnicalReviewClick(row){//药品生产--材料审查--新
            this.setOfData = {
                ...this.setOfData,
                isReadOnly:true,
                isOwn:false,
                
            }
            this.$refs[row.ref+'Ref'].visible = true
            this.$refs[row.ref+'Ref'].spinning = true
            this.$refs[row.ref+'Ref'].getData(this.setOfData)
        },
        manufacturingReturnGovernmentClick(row){//药品生产--退回政务
            this.setOfData = {
                ...this.setOfData,
                isReadOnly:true,
                isOwn:false,
                
            }
            this.$refs[row.ref+'Ref'].visible = true
            this.$refs[row.ref+'Ref'].spinning = true
            this.$refs[row.ref+'Ref'].getData(this.setOfData)
        },
        manufacturingCompleteAndCorrectClick(row){//药品生产--补齐补正
            this.setOfData = {
                ...this.setOfData,
                isReadOnly:true,
                isOwn:false,
                
            }
            this.$refs[row.ref+'Ref'].visible = true
            this.$refs[row.ref+'Ref'].spinning = true
            this.$refs[row.ref+'Ref'].getData(this.setOfData)
        },

        manufacturingPlanProductionClick(row){//药品生产--方案制定
            this.setOfData = {
                ...this.setOfData,
                isReadOnly:true,
                isOwn:false,
                commpStepIndex:row.fhjmc == '方案制定'?2:(row.fhjmc == '方案审核'?3:4),
            }
            this.$refs[row.ref+'Ref'].visible = true
            this.$refs[row.ref+'Ref'].spinning = true
            this.$refs[row.ref+'Ref'].getData(this.setOfData)
        },
        manufacturingOnSiteInspectionClick(row){//药品生产--技术审评
            this.setOfData = {
                ...this.setOfData,
                isReadOnly:true,
                isOwn:false,
                commpStepIndex:5,
                fullscreen:row.fullscreen,
            }
            this.$refs[row.ref+'Ref'].visible = true
            this.$refs[row.ref+'Ref'].spinning = true
            this.$refs[row.ref+'Ref'].getData(this.setOfData)
        },
        manufacturingComprehensiveClick(row){//药品生产--综合评定
            this.setOfData = {
                ...this.setOfData,
                isReadOnly:true,
                isOwn:false,
                commpStepIndex:row.fhjmc == '综合评定'?6:(row.fhjmc == '科室复核'?7:8),
            }
            this.$refs[row.ref+'Ref'].visible = true
            this.$refs[row.ref+'Ref'].spinning = true
            this.$refs[row.ref+'Ref'].getData(this.setOfData)
        },
        departmentReviewClick(row){
            this.setOfData = {
                ...this.setOfData,
                isReadOnly:true,
                isOwn:false,
                commpStepIndex:row.fhjmc == '科室复核'?7:8,
            }
            this.$refs[row.ref+'Ref'].visible = true
            this.$refs[row.ref+'Ref'].spinning = true
            this.$refs[row.ref+'Ref'].getData(this.setOfData)
        },
    }
}
</script>